import Parser from './parser';
import type { LifeCyclesParserContructorProps, LifeCyclesParserProps, PackagesParserProps, SourceCode } from '../types';
export default class LifeCyclesParser extends Parser implements LifeCyclesParserProps {
  private packagesParser: PackagesParserProps;
  constructor({ packagesParser, ...props }: LifeCyclesParserContructorProps) {
    super(props);
    this.packagesParser = packagesParser;
  }
  async parse(): Promise<SourceCode['lifeCycles']> {
    const lifeCycles = await super.parseLifeCycles();
    if (lifeCycles) {
      this.packagesParser.setEnvironmentPackages({
        packageName: 'react',
        subName: ['useEffect'],
      });
    }
    return lifeCycles;
  }
}
